package com.av.bcacc.javaapi.thread.productor;

public class Foodie extends Thread {
    @Override
    public void run() {
        while (true) {
            synchronized (Desk.objLock) {
                if (Desk.HAS_FLAG) {
                    try {
                        System.out.println(Thread.currentThread().getName() + "---开吃...");
                        Thread.sleep(1000);
                        System.out.println(Thread.currentThread().getName() + "---吃完了,通知厨师开始生产...");
                        Desk.HAS_FLAG = false;
                        Desk.objLock.notifyAll();
                        Desk.objLock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }

        }
    }
}
